/*
 * @Author: MrDotYan 2564217790@qq.com
 * @Date: 2024-08-26 10:41:26
 * @LastEditors: MrDotYan 2564217790@qq.com
 * @LastEditTime: 2024-09-20 14:29:11
 * @FilePath: /webServerAdmin/src/utils/date.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import dayjs from "dayjs";

/**
 * 获取更详细的时间戳
 * @param date
 * @returns
 */
export function timestamp(date = new Date()) {
  return dayjs(date).valueOf();
}

/**
 * 获取unixs时间戳
 * @param date
 * @returns
 */
export function unix(date = new Date()) {
  return dayjs(date).unix();
}

/**
 * 格式化时间
 * @param date
 * @param patten
 * @returns
 */
export function fmt(date: Date | string = new Date(), patten = "YYYY-MM-DD HH:mm:ss") {
  return dayjs(date).format(patten);
}
